package Operate;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

//查找图书
public class FindOperate implements IOOperate{
    @Override
    public void work(BookList bookList) {
        //获得书名
        System.out.println("Find");
        System.out.println("book-name:");
        Scanner scanner = new Scanner(System.in);
        String bookName = scanner.nextLine();

        //获取书架书籍数目
        int bookSize = bookList.getBookNumber();
        for (int i = 0; i < bookSize; i++) {
            //获得书籍信息
            Book book = bookList.getBook(i);
            //对比书籍名称
            if(bookName.equals(book.getName())){
                System.out.println("Found");
                System.out.println(book);
                return;
            }
        }
        System.out.println("Don't find");
    }
}
